<template>  
  <div>  
    <h1>登录</h1>  
    <form @submit.prevent="login">  
      <label for="username">账号:</label>  
      <input type="text" id="username" v-model="username" required>  
      <label for="password">密码:</label>  
      <input type="password" id="password" v-model="password" required>  
      <button type="submit">登录</button>  
    </form>  
    <p v-if="error">{{ error }}</p>  
  </div>  
</template>  
  
<script>  
export default {  
  name: 'Login',  
  data() {  
    return {  
      username: '',  
      password: '',  
      error: '',  
    };  
  },  
  methods: {  
    login() {  
      if (this.username === 'admin' && this.password === '123456') {  
        // 这里可以处理登录成功后的逻辑，比如跳转到主页或存储用户信息等  
        this.$router.push('/'); // 假设登录成功后跳转到主页  
      } else {  
        this.error = '账号或密码错误';  
      }  
    },  
  },  
};  
</script>